 
export const getParams = (json)=>{
	 return Object.keys(json).map(function (key) {  return encodeURIComponent(key) + "=" + encodeURIComponent(json[key]); }).join("&")
} 
const host = "http://127.0.0.1:8081" 
export const api = (url,data,method='POST')=>{  
	var token =   uni.getStorageSync('token');
	var header = {"content-type":"application/json",}
	if(token) header = Object.assign({},header,{ "Authorization":`Bearer ${token}`,})
	return new Promise( function (resolve, reject) {
	   uni.request({ url: host + url,  method: method,   dataType: 'json',  
	      header:header, 
		  data:data,
		  success: function(res) { resolve(res.data) }, fail: function(err) {  reject(err) }
	    })
	})  
}
 
export const profile =()=>{
	return api("/system/user/profile",{},'GET')
}
 
